<?php
class Evaluator {
	private $ticker;
	private $name;
	private $exchange;
	private $price;
	private $pe;
	private $pb;
	private $total_debt;
	private $total_equity;
	private $current_liabilities;
	private $total_liabilities;
	private $current_assets;
	private $total_assets;
	private $net_fixed_assets;
	private $ebit;
	private $net_income;
	private $nb_shares;
	private $anualised_dividend;
	private $federal_note;
	
	private $nb_years_bookvalue;
	private $bookvalue2012;
	private $bookvalue2011;
	private $bookvalue2010;
	private $bookvalue2009;
	private $bookvalue2008;
	private $bookvalue2007;
	private $bookvalue2006;
	private $bookvalue2005;
	private $bookvalue2004;
	private $bookvalue2003;
	private $bvg2012;
	private $bvg2011;
	private $bvg2010;
	private $bvg2009;
	private $bvg2008;
	private $bvg2007;
	private $bvg2006;
	private $bvg2005;
	private $bvg2004;
	
	private $nb_years_eps;
	private $avg_eps_growth;
	private $avg_eps;
	private $eps2012;
	private $eps2011;
	private $eps2010;
	private $eps2009;
	private $eps2008;
	private $eps2007;
	private $eps2006;
	private $eps2005;
	private $eps2004;
	private $eps2003;
	private $epsg2012;
	private $epsg2011;
	private $epsg2010;
	private $epsg2009;
	private $epsg2008;
	private $epsg2007;
	private $epsg2006;
	private $epsg2005;
	private $epsg2004;
	
	
	private $average_growth;
	private $average_growth_modified;
	private $future_bookvalue;
	private $debt_on_equity;
	private $current_ratio;
	private $eps;
	
	private $dividend_on_eps;
	private $roe;
	private $intrinsic_value;
	private $expected_anual_return;
	
	// The constructor, duh!
	function __construct(){
	}
	
	
	public function __get($property) {
		if (property_exists($this, $property)) {
			return $this->$property;
		}
	}
	
	public function __set($property, $value) {
		if (property_exists($this, $property)) {
			$this->$property = $value;
		}
		
		return $this;
	}
	
	function bar(){
		return 'foo';
	}
	
	function getROE(){
		return $this->net_income / $this->total_equity;
	}
	function getEPS(){
		return round($this->net_income / $this->nb_shares,2);
	}
	function getDividendOnEPS(){
		return $this->anualised_dividend / $this->getEPS();
	}
	function getEPSonPrice(){
		return $this->eps2012 / $this->price;
	}
	function getAVGEPSonPrice(){
		return $this->avg_eps / $this->price;
	}
	function getFBV(){
		return round($this->bookvalue2012*pow((1+$this->average_growth),10),2);
	}
	function getFBVp($bookvalue, $growth){
		return round($bookvalue*pow((1+$growth),10),2);
	}
	function getIntrinsicValue(){
		$i = $this->average_growth;
		$l = $this->federal_note;
		$n = 10;
		$fbv = $this->getFBV();
		$div = $this->anualised_dividend;
		return  $div*((1-(1/(pow((1+$l),10))))/$l) +$fbv/(pow((1+$l),10));
	}
	function getIntrinsicValuep($bookvalue, $growth, $fednote, $dividend){
		$i = $growth;
		$l = $fednote;
		$n = 10;
		$fbv = $this->getFBVp($bookvalue, $growth);
		$div = $dividend;
		return  $div*((1-(1/(pow((1+$l),10))))/$l) + $fbv/(pow((1+$l),10));
	}
	function getExpectedAnualReturn(){
		$i = $this->average_growth;
		$l = $this->federal_note;
		$n = 10;
		$fbv = $this->getFBV();
		$div = $this->anualised_dividend;
		
		$p = $this->price;
		
		return pow(($fbv / ($p - $div*((1-(1/(pow((1+$i),10))))/$i))),(1/$n))-1;
	}
	function getPE(){
		return $this->price / $this->getEPS();
	}
	function getPB(){
		return $this->price / $this->bookvalue2012;
	}
	function getDebtOnEquity(){
		return $this->total_debt / $this->total_equity;
	}
	function getCurrentRatio(){
		return $this->current_assets / $this->current_liabilities;
	}
	function getFinancialIndependence(){
		return $this->total_equity / $this->total_assets;
	}
	function getConstrictedFinancialIndependence(){
		return $this->total_equity / $this->total_liabilities;
	}
	function getWorkingCapital(){
		return $this->current_assets - $this->current_liabilities;
	}
	
	function getReturnOnCapitalEmployed(){
		return $this->ebit / ($this->getWorkingCapital() + $this->net_fixed_assets);
	}
}
?>